/*
 * Created on Mar 22, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.vectrics.common.util;

import java.io.InputStream;

import org.apache.log4j.Logger;

/**
 * @author mmoore
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class StreamUtils {
	private transient static Logger log = Logger.getLogger(StreamUtils.class);
	
	public static String inputStreamToString(InputStream stream) {
		StringBuffer str = new StringBuffer();
		try {
			boolean done = false;
			while (done == false) {
				int i = stream.read();
				if (i >= 0) {
					char c = (char)i;
					str.append(c);
				}
				else {
					done = true;
				}
			}
		}
		catch (Exception ex) {
			log.error("Exception reading stream", ex);
		}
		return(str.toString());
	}

}
